package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public class CopyDemo {
    public static void main(String[] args) {
        try (
             FileInputStream fis = new FileInputStream("img.jpg");
             FileOutputStream fos = new FileOutputStream("copy2.jpg")
        ) {
            int d;
            long start = System.currentTimeMillis();
            while ((d = fis.read())!=-1) {
                    fos.write(d);
            }
            long ends = System.currentTimeMillis();
            System.out.println("耗时:"+(ends-start)+"ms");
            } catch(Exception e){
                e.printStackTrace();
        }
    }
}
